<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
		<title>一覧</title>
<script LANGUAGE="javascript">
	function showSubWin(url) {
		window.open(url)
	}
	function checkboxclick() {
		var all_select = document.getElementById("all_select").value;
    	if(all_select != "" && all_select != null)
    	{
    		return true;
    	}
    	alert("選択対象を1件以上指定して下さい");
		return false;
	}
	function checkSearch() {
	    var check = /^(19|20)[0-9]{2}$/;
		var startDateY = document.getElementById('startDateY');
		var startDateM = document.getElementById('startDateM');
		var startDateD = document.getElementById('startDateD');
		var endDateY = document.getElementById('endDateY');
		var endDateM = document.getElementById('endDateM');
		var endDateD = document.getElementById('endDateD');
		if (startDateY.value != "") {
			if (check.test(startDateY.value) == false) {
				alert("検出日付_FROM年を入力不正");
				document.all("startDateY").focus();
				document.all("startDateY").select();
				return false;
			}
			if (startDateM.value == "") {
				alert("検出日付_FROM月を選択してください");
				document.all("startDateM").focus();
				return false;
			}
			if (startDateD.value == "") {
				alert("検出日付_FROM日を選択してください");
				document.all("startDateD").focus();
				return false;
			}
			if (!realDateCheck(startDateY.value,startDateM.value,startDateD.value,"startDate")) {
				return false;
			}
		} else {
			if (startDateM.value != "" || startDateD.value != "") {
				alert("検出日付_FROM年を入力してください");
				document.all("startDateY").focus();
				document.all("startDateY").select();
				return false;
			}
		}
		if (endDateY.value != "") {
			if (check.test(endDateY.value) == false) {
				alert("検出日付_TO年を入力不正");
				document.all("endDateY").focus();
				document.all("endDateY").select();
				return false;
			}
			if (endDateM.value == "") {
				alert("検出日付_TO月を選択してください");
				document.all("endDateM").focus();
				return false;
			}
			if (endDateD.value == "") {
				alert("検出日付_TO日を選択してください");
				document.all("endDateD").focus();
				return false;
			}
			if (!realDateCheck(endDateY.value,endDateM.value,endDateD.value,"endDateD")) {
				return false;
			}
		} else {
			if (endDateM.value != "" || endDateD.value != "") {
				alert("検出日付_TO年を入力してください");
				document.all("endDateY").focus();
				document.all("endDateY").select();
				return false;
			}
		}
		var l_start = startDateY.value + startDateM.value + startDateD.value;
		var l_end = endDateY.value + endDateM.value + endDateD.value;
		if (l_start != "" && l_end != "" && l_end < l_start) {
			alert("検出日付_TOが、検出日付_FROMより過去日付になっているので修正して下さい。");
			return false;
		}
		return true;
	}
	
	function realDateCheck(y,m,d,strDate) {
			if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
                if(d < 1 || d > 31) {
                    alert("検出日付は實在日付エラー");
                    document.all(strDate+"D").focus();
                    return false;
                }
            } else {
                if(m == 2) {
                    if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) {
                        if(d < 1 || d > 29) {
                            alert("検出日付は實在日付エラー");
                            document.all(strDate+"D").focus();
                            return false;
                        }
                    } else {
                        if(d < 1 || d > 28) {
                            alert("検出日付は實在日付エラー");
                            document.all(strDate+"D").focus();
                            return false;
                        }
                    }
                } else {
                    if(d < 1 || d > 30) {
                        alert("検出日付は實在日付エラー");
                        document.all(strDate+"D").focus();
                        return false;
                    }
                }
            }
            return true;
	}
	function pageChange(clickpage){
		document.getElementById("pageNow").value = clickpage;
	    document.listform.action = "sgpagecut.action";
		document.listform.submit();
	}
	function viewCheckBox()
	{
	    var checkboxes = document.getElementsByName("banGos");
	    var all_select_obj = document.getElementById("all_select");
	    var all_select = all_select_obj.value;
	
	    for(i = 0; i < checkboxes.length; i ++ )
	    {
	        var checkbox = checkboxes[i];
	        if(checkbox.checked)
	        {
	            if(all_select.indexOf("[" + checkbox.value + "]") == - 1)
	            {
	                all_select += ",[" + checkbox.value + "]";
	            }
	        }
	        else
	        {
	            if(all_select.indexOf(",[" + checkbox.value + "]") != - 1)
	            {
	                all_select = all_select.replace(",[" + checkbox.value + "]", "");
	            }
	            else if(all_select.indexOf("[" + checkbox.value + "]") != - 1)
	            {
	                all_select = all_select.replace("[" + checkbox.value + "]", "");
	            }
	        }
	    }
	    if(all_select.substring(0, 1) == "," && all_select.length > 1)
	    {
	        all_select = all_select.substring(1, all_select.length);
	    }
	    all_select_obj.value = all_select;
	}
	function initCheckBox()
	{  
	    var all_select = document.getElementById("all_select").value;
	    if(all_select != "" && all_select != null)
	    {
	        while(all_select.indexOf("[") != - 1 || all_select.indexOf("]") != - 1)
	        {
	            var all_select = all_select.replace("[", "").replace("]", "");
	        }
	        var arrall_select = all_select.split(",");
	        var checkBoxs = document.getElementsByName("banGos");
	        if(arrall_select.length > 0)
	        {
	            for(k = 0; k < arrall_select.length; k ++ )
	            {
	                for(i = 0; i < checkBoxs.length; i ++ )
	                {
	                    if(checkBoxs[i].value == arrall_select[k])
	                    {
	                        checkBoxs[i].checked = true;
	                    }
	                }
	            }
	        }
	    }
	}
	function checkAllBox()
	{
		var checkAll = document.getElementById("checkAll");
		var checkboxes = document.getElementsByName("banGos");
		if(checkAll.checked){
			for(i = 0; i < checkboxes.length; i ++ )
    		{
    			checkboxes[i].checked = true;
    		}
		}
		else
		{
			for(i = 0; i < checkboxes.length; i ++ )
    		{
    			checkboxes[i].checked = false;
    		}
		}
		viewCheckBox();
	}
	function quickSearchbtn(type){
		document.getElementById("quickSearchbutton").value = type;
		return true;
	}
	</script>
	<style type="text/css">
		div#viewEditArea div.guideMsg{
			padding-left:2ex;
			color:#993300;
			font-size:12px;
		}
		fieldset {
           padding:10px;
           margin-top:5px;
           border:1px solid #A4CDF2;
           font-size:12px;
        }
        fieldset legend {
          font-weight:bold;
          font-size:15px;
   
        }
		col.item1{
			width:30%;
		}
		col.value{
			width:70%;
		}
		col.col1{
			width:4%;
		}
		col.col2{
			width:10%;
		}
		col.col3{
			width:5%;
		}
		col.col4{
			width:5%;
		}
		col.col5{
			width:6%;
		}
		col.col6{
			width:6%;
		}
		col.col7{
			width:8%;
		}
		col.col8{
			width:8%;
		}
		col.col9{
			width:14%;
		}
		col.col10{
			width:10%;
		}
		col.col11{
			width:12%;
		}
		col.col12{
			width:20%;
		}
		
		div#contentArea table.pol_list{
			border-style:none;
			border-collapse:collapse;
			width:100%;
			margin-top:1ex;
			font-size:12px;
		}
		table.pol_list th{
			border-style:solid;
			border-width:0.2ex;
			border-color:#A4CDF2;
			background-color:#87cefa;
			vertical-align:middle;
			text-align:center;
			padding:0.5ex 0.3ex;
			font-size:12px;
		}
		table.pol_list td{
			border-style:solid;
			border-width:0.2ex;
			border-color:#A4CDF2;
			background-color:#eeeeee;
			vertical-align:middle;
			text-align:center;
			padding:0.5ex 0.5ex;
			font-size:12px;
		}

		table.pol_list td.kingaku{
			text-align:right;
			font-size:12px;
		}
		table.pol_list td.kingaku2{
			text-align:right;
			vertical-align:top;
			font-size:12px;
		}
		table.pol_list td.sentaku{
			text-align:left;
			font-size:12px;
		}
		table.pol_list td.name{
			text-align:left;
			font-size:12px;
		}
		table.pol_list td.name2{
			text-align:left;
			vertical-align:top;
			font-size:12px;
		}
		table.pol_list td.check{
			width:4%;
			font-size:12px;
		}
		table.pol_list td.check2{
			vertical-align:top;
			font-size:12px;
		}
		table.pol_list th.left{
			text-align:left;
			font-size:12px;
		}
		table.pol_list td.siborikomi_msg{
			text-align:left;
			color:red;
			padding-left:3ex;
			font-size:12px;
		}
	  .select{
        width:140px;
        border-right: #000000 1px solid;
        border-top: #ffffff 1px solid;
        border-left: #ffffff 1px solid;
        color:#003366;
        border-bottom: #000000 1px solid;
        background-color: #f4f4f4;
        font-size:12px;
    }
     .select_m{
        border-right: #000000 1px solid;
        border-top: #ffffff 1px solid;
        border-left: #ffffff 1px solid;
        color:#003366;
        border-bottom: #000000 1px solid;
        background-color: #f4f4f4;
        font-size:12px;
    }
    .test{
		width:40px;
		color:#003366;
		font-size:12px;
		}
	.btn1{
	   BORDER-RIGHT: #2C59AA 1px solid; 
	   PADDING-RIGHT: 2px; 
	   BORDER-TOP: #2C59AA 1px solid; 
	   PADDING-LEFT: 2px; 
	   FONT-SIZE: 12px; 
	   FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#C3DAF5); 
	   BORDER-LEFT: #2C59AA 1px solid; 
	   CURSOR: hand; 
	   COLOR: black; 
	   PADDING-TOP: 2px; 
	   BORDER-BOTTOM: #2C59AA 1px solid;
	} 
	table.ctrl td{
			vertical-align:middle;
			text-align:center;
			padding:0.5ex 0.5ex;
			font-size:12px;
	}
	col.ctrlcol{
			width:30%;
	}
	col.ctrlcol1{
			width:40%;
	}
	col.ctrlcol2{
			width:30%;
	}
	.test_textfield{
		width:140px;
		color:#003366;
		font-size:12px;
		}
</style>

</head>
<body text=#003366 onload="initCheckBox();">
<s:form name="listform" method="POST">
<input type="hidden" id="all_select" name="all_select" value="<s:property value="all_select"/>" />

<div id="viewEditArea">
	<table cellpadding="0" cellspacing="0" width="100%" bgcolor=RGB(238,242,251)>
	<tr><td style="font-size:15px;color:#3568cc;"><b>障害管理</b></td></tr>
	</table>
	
<fieldset>
<legend>検索設定</legend>	
	<div id="contentArea">	
	<table>
		<tr>
	         <td style="font-size:12px;">プロジェクト</td>
	        <td>
		        <s:select theme="simple" cssClass="select" name="search.projectId" headerKey="" headerValue="" list="projectList" listKey="projectId" listValue="projectName" value="search.projectId" />
	        </td>
	    </tr>
	    <tr>
	         <td style="font-size:12px;">テーマ名</td>
	        <td>
		        <s:select theme="simple" cssClass="select" name="search.tema" headerKey="" headerValue="" list="functionArray" listKey="theme_id" listValue="theme_name" value="search.tema" />
	        </td>
	    </tr>
	     <tr>
	         <td style="font-size:12px;">テスト段階</td>
	        <td>
		        <s:select theme="simple" cssClass="select" name="search.test_lvl" headerKey="" headerValue="" list="testlvlArray" listKey="master_value" listValue="master_value" value="search.test_lvl" />
	        </td>
	    </tr>
	    <tr>
	         <td style="font-size:12px;">検出側</td>
	        <td>
		        <s:select theme="simple" cssClass="select" name="search.test_part" headerKey="" headerValue="" list="testPartArray" listKey="master_value" listValue="master_value" value="search.test_part" />
	        </td>
	    </tr>
	    <tr>
	        <td style="font-size:12px;">検出者</td>
	        <td>
		        <s:select theme="simple" cssClass="select" name="search.tester" headerKey="" headerValue="" list="testerArray" listKey="user_disp_value" listValue="user_disp_value" value="search.tester" />
	        </td>
	    </tr>
	    <tr>
	        <td style="font-size:12px;">修正担当</td>
	        <td>
		        <s:select theme="simple" cssClass="select" name="search.modify" headerKey="" headerValue="" list="modifyArray" listKey="user_disp_value" listValue="user_disp_value" value="search.modify" />
	        </td>
	    </tr>
	    <tr>
	    　　　　　<td style="font-size:12px;">ステータス</td>
	        <td>
		        <s:select theme="simple" cssClass="select" name="search.status" headerKey="" headerValue="" list="statusArray" listKey="master_value" listValue="master_value" value="search.status" />
	        </td>
	    </tr>
	    <tr>
	    　　　　　<td style="font-size:12px;">障害要因</td>
	        <td>
		        <s:select theme="simple" cssClass="select" name="search.reason" headerKey="" headerValue="" list="reasonArray" listKey="master_value" listValue="master_value" value="search.reason"/>
	        </td>
	    </tr>
        <tr>
			<td style="font-size:12px;">検出日</td>
			<td style="font-size:12px;">
				<s:textfield id="startDateY" name="search.testStartDate_Y" theme = "simple" size="2" maxlength="4" cssClass="test"/>年
				<s:select id="startDateM" name="search.testStartDate_M" headerKey="" headerValue="" list="monthArray" value="search.testStartDate_M" theme = "simple" cssClass="select_m"/>月
				<s:select id="startDateD" name="search.testStartDate_D" headerKey="" headerValue="" list="dayArray" value="search.testStartDate_D" theme = "simple" cssClass="select_m"/>日~
				<s:textfield id="endDateY" name="search.testEndDate_Y" theme = "simple" size="2" maxlength="4" cssClass="test"/>年
				<s:select id="endDateM" name="search.testEndDate_M" headerKey="" headerValue="" list="monthArray" value="search.testEndDate_M" theme = "simple" cssClass="select_m"/>月
				<s:select id="endDateD" name="search.testEndDate_D" headerKey="" headerValue="" list="dayArray" value="search.testEndDate_D" theme = "simple" cssClass="select_m"/>日
			</td>			
		</tr>
         <tr>
	    　　　　　<td style="font-size:12px;">キー</td>
	        <td>
		        <s:textfield  name="search.key"  theme = "simple" cssClass="test_textfield" />
	        </td>
	    </tr>
        
	</table>
    <table width="100%">
    <tr>
    <td width="10"><img src="Img/btn_search_box.gif" width="27" height="20" alt="Search" align="right"/></td>
	<td width="20"><s:submit btnId="D001" action = "listSG" value = "検      索" theme = "simple" onclick="return checkSearch();" cssClass="btn1"/></td>
	<td width="20"><s:submit btnId="D002" action = "allSG" value = "全      件" theme = "simple" cssClass="btn1"/></td>
    <td></td><td></td><td></td>
    <td width="20"><img src ="Img/4.bmp" align="right" alt="newSG"></td><td width="50"><s:submit btnId="D003" action = "newSG" value = "新      規" theme = "simple" cssClass="btn1"/></td>
	</tr>
    </table> 
   </div>
</fieldset>
<fieldset>
  <legend>業務検索</legend>
		<table cellpadding="0" cellspacing="0" width="100%" bgcolor=RGB(238,242,251)>
		  <tr bgcolor=RGB(238,242,251)>			   
		  <td><img src ="Img/2.bmp" align="right"></td><td align="left"><s:submit btnId="D004" action = "quickSearchSG" value = "  業 務SU  " theme = "simple" onclick="return quickSearchbtn('btn_1');" cssClass="btn1"/></td>
		  <td><img src ="Img/2.bmp" align="right"></td><td align="left"><s:submit btnId="D005" action = "quickSearchSG" value = "内部管理SU " theme = "simple"  onclick="return quickSearchbtn('btn_2');" cssClass="btn1"/></td>
		  <td><img src ="Img/2.bmp" align="right"></td><td align="left"><s:submit btnId="D006" action = "quickSearchSG" value = " 保険金SP " theme = "simple"  onclick="return quickSearchbtn('btn_3');" cssClass="btn1"/></td>
		  <td><img src ="Img/2.bmp" align="right"></td><td align="left"><s:submit btnId="D007" action = "quickSearchSG" value = "ＶＢ現行廃止" theme = "simple" onclick="return quickSearchbtn('btn_4');" cssClass="btn1"/></td>
		  </tr>
		</table>
</fieldset>
	
<s:if test="null != zhlists">
    <fieldset>
	<legend>障害一覧</legend>
	<table class="pol_list">
	        <col class="col1">
			<col class="col1">
			<col class="col2">
			<col class="col11">
			<col class="col4">
			<col class="col5">
			<col class="col6">
			<col class="col7">
			<col class="col8">
			<col class="col9">
			<col class="col10">
			<col class="col3">
			<col class="col12">
			<tr>
			    <th><input type="checkbox" id="checkAll" name="checkAll" value="チエック" onclick="checkAllBox();" /></th>
				<th>番号</th>
				<th>プロジェクト</th>
				<th>テーマ名</th>
				<th>段階</th>
				<th>検出側</th>
				<th>検出者</th>
				<th>検出日</th>
				<th>ステータス</th>
				<th>概要</th>
				<th>対応期限</th>
				<th>修正担当</th>
				<th>障害要因</th>

			</tr>
			<s:iterator value="zhlists">
			<tr id="zhlist<s:property value="no"/>">
				<td>
				<input type="checkbox" id="banGos" name="banGos" value='<s:property value="no"/>' onclick="viewCheckBox();" />
				</td>
				<td><s:property value="no"/></td>
				<td><s:property value="project"/></td>
				<td><s:property value="tema"/></td>
				<td><s:property value="test_lvl"/></td>
				<td><s:property value="test_part"/></td>
				<td><s:property value="tester"/></td>
				<td><s:property value="test_date"/></td>
				<td><s:property value="status"/></td>
				<td><a href="JavaScript:void(0)" onClick="showSubWin('detailSG.action?no=<s:property value="no"/>')"><s:property value="memo"/></a></td>
				<td><s:property value="limit_date"/></td>
				<td>
         <s:if test="modify !='' "><s:property value="modify"/></s:if>
        <s:else>&nbsp;</s:else>
				</td>
               <td>
      <s:if test="reason !='' "><s:property value="reason"/></s:if>
      <s:else>&nbsp;</s:else>
              </td>
			</tr>
			</s:iterator>
	</table>
    <div align="center">
    <span>
     <s:if test="pagePre == 0">
     	<a>前のページ</a>
     </s:if>
     <s:else>
   	 	<a  href="JavaScript:pageChange('<s:property value="pagePre"/>');">前のページ</a>
   	 </s:else>
   	 <s:if test="totalPages < pageNext">
     	<a>后のページ</a>
     </s:if>
     <s:else>
   	 	<a  href="JavaScript:pageChange('<s:property value="pageNext"/>');">后のページ</a>
   	 </s:else>
     </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     <b><span align="right">
       <s:if test="pageNow > totalPages">
			0/0
		</s:if>
		<s:else>
			<s:property value="pageNow"/>/<s:property value="totalPages"/>
		</s:else>
      </span></b>
      </div>
     <input type="hidden" id="pageNow" name="pageNow" value="">
<table cellspacing="10" summary="隙間用"><tr><td></td></tr></table>
<table cellpadding="0" cellspacing="0" width="100%" bgcolor=RGB(238,242,251)>
	<tr bgcolor=RGB(238,242,251)>			   
		<td><img src ="Img/1.bmp" align="right" alt="delete"></td><td align="left"><s:submit btnId="D008" action = "deleteSG" value = "削      除" theme = "simple" onclick="return checkboxclick();" cssClass="btn1"/></td>
		<td><img src ="Img/2.bmp" align="right" alt="export"></td><td align="left"><s:submit btnId="D009" action = "exportSG" value = "エクスポート" theme = "simple" onclick="return checkboxclick();" cssClass="btn1"/></td>
	</tr>
</table>
	</fieldset>
</s:if>
<input type="hidden" id="quickSearchbutton" name="quickSearchbuttonID" value="">
</s:form>

</body>
</html>